package edu.uci.ics.xmlrpc.webserver;

import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServer;
import org.apache.xmlrpc.webserver.ServletWebServer;
import org.apache.xmlrpc.webserver.XmlRpcServlet;

public class ChatterServletServer
{
	private static final int port = 8080; // can't run a Client and Server on same port

    public static void main(String[] args) throws Exception {    	
    	XmlRpcServlet servlet = new ChatterServer();
        System.out.println("Starting server (SERVER)...");
        
        ServletWebServer webServer = new ServletWebServer(servlet, port);
        
        XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer();
        
        /* You may also provide the handler classes directly,
         * like this:
         * phm.addHandler("Calculator",
         *     org.apache.xmlrpc.demo.Calculator.class);
         * phm.addHandler(org.apache.xmlrpc.demo.proxy.Adder.class.getName(),
         *     org.apache.xmlrpc.demo.proxy.AdderImpl.class);
         */
        
        PropertyHandlerMapping phm = new PropertyHandlerMapping();
        phm.addHandler("ChatterServer", edu.uci.ics.xmlrpc.webserver.ChatterServer.class);

        xmlRpcServer.setHandlerMapping(phm);
        
        webServer.start();
        System.out.println("Server started (SERVER)");
    }
}
